/*****************************************************************************************
 * FILE NAME: drv_i2c                       COPYRIGHT (c) cos 2024
 * REVISION:  1.0.0                                     All Rights Reserved
 * DESCRIPTION:
 * =======================================================================================
 * UPDATE HISTORY:
 * REV      AUTHOR      DATE
 * v1.0.0   Tuxin       2024.10.14
 * DESCRIPTION OF CHANGE:
 ****************************************************************************************/
#ifndef __DRV_I2C_H
#define __DRV_I2C_H

//----------------------------------------------------------------------------------------
// @Project Includes
#include "typedefs.h"

//----------------------------------------------------------------------------------------
// @Global Macro Define in the module

#define I2C_SCL_PIN               (GPIO_PIN_15)
#define I2C_SDA_PIN               (GPIO_PIN_14)
#define I2C_SCL_PORT            	(GPIOB)
#define I2C_SDA_PORT            	(GPIOB)

#define I2C_SCL_LOW()         		GPIO_ResetBits(I2C_SCL_PORT,I2C_SCL_PIN)
#define I2C_SCL_HIGH()        		GPIO_SetBits(I2C_SCL_PORT,I2C_SCL_PIN)
#define I2C_SDA_LOW()         	  GPIO_ResetBits(I2C_SDA_PORT, I2C_SDA_PIN)
#define I2C_SDA_HIGH()        		GPIO_SetBits(I2C_SDA_PORT, I2C_SDA_PIN)
#define I2C_SDA_READPIN()         GPIO_ReadInputDataBit(I2C_SDA_PORT,I2C_SDA_PIN)

//----------------------------------------------------------------------------------------
// @Global Type defines in the module

//----------------------------------------------------------------------------------------
// @Export global Variables declare in the module

//----------------------------------------------------------------------------------------
// @Export declaration of functions in the module
void drv_i2c_sleep(void);
void drv_i2c_wakeup(void);
void drv_i2c_init(void);

bool_t drv_i2c_write(uint8_t uDeviceAddr, uint8_t uCellAddr, uint8_t * puBuf, uint8_t uNum);
bool_t drv_i2c_read(uint8_t uDeviceAddr, uint8_t uCellAddr, uint8_t * puBuf, uint8_t uNum);
bool_t drv_i2c_readSh367306(uint8_t uDeviceAddr, uint8_t uCellAddr, uint16_t * puBuf);
bool_t drv_i2c_dvcTransferData(uint8_t *writeData, uint16_t writeLen, uint8_t *readData, uint16_t readLen);

#endif

// =======================================================================================
// End of file.
// =======================================================================================
